﻿#region Copyright information
// 
// Copyright © 2005-2013 Yongkee Cho. All rights reserved.
// 
// This code is a part of the Biological Object Library and governed under the terms of the
// GNU Lesser General  Public License (LGPL) version 2.1 which accompanies this distribution.
// For more information on the LGPL, please visit http://bol.codeplex.com/license.
// 
// - Filename: SequenceEqualityComparer.cs
// - Author: Yongkee Cho
// - Email: yongkeecho@gmail.com
// - Date Created: 2012-09-27 11:16 AM
// - Last Modified: 2013-01-25 3:59 PM
// 
#endregion
using System.Collections.Generic;
using System.Linq;

namespace BOL.Collections.Generics
{
    public class SequenceEqualityComparer<T> : IEqualityComparer<IEnumerable<T>>
    {
        public bool Equals(IEnumerable<T> first, IEnumerable<T> second)
        {
            return first.SequenceEqual(second);
        }

        public int GetHashCode(IEnumerable<T> source)
        {
            return source.Aggregate(1, (hashCode, current) => hashCode ^ current.GetHashCode());
        }
    }
}